Skip to content

BUG: can't round-trip non-nano Timestamp #51087

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Feb 9, 2023

Conversation

MarcoGorelli
Copy link
Member

This should fix the interger case, but not the float one, so let's still keep the issue open for now

@mroeschke mroeschke added the Non-Nano datetime64/timedelta64 with non-nanosecond resolution label Jan 31, 2023
@MarcoGorelli MarcoGorelli marked this pull request as draft February 7, 2023 12:28
@MarcoGorelli MarcoGorelli marked this pull request as ready for review February 7, 2023 17:55
elif reso == NPY_DATETIMEUNIT.NPY_FR_M:
# 2629746 comes from dividing the "Y" case by 12.
m = 1_000_000_000 * 2629746
p = 9
m = multiplier * 2629746
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure the M and Y cases in precision_from_unit are no longer reached, in which case the entire m part of this function i think can be replaced with get_conversion_factor (OK to consider out of scope)

MarcoGorelli added 2 commits February 8, 2023 16:07
@@ -294,9 +296,15 @@ cdef _TSObject convert_to_tsobject(object ts, tzinfo tz, str unit,
if ts == NPY_NAT:
obj.value = NPY_NAT
else:
ts = cast_from_unit(ts, unit)
if unit is None:
in_reso = abbrev_to_npy_unit("ns")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we assign unit="ns" here since we pass it to cast_from_unit below?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK for follow-up

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, good one, thanks

Copy link
Member

@jbrockmendel jbrockmendel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one comment for a follow-up

@MarcoGorelli MarcoGorelli added this to the 2.0 milestone Feb 9, 2023
@MarcoGorelli
Copy link
Member Author

Thanks for your review!

@MarcoGorelli MarcoGorelli merged commit 0e8331f into pandas-dev:main Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Non-Nano datetime64/timedelta64 with non-nanosecond resolution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants